package com.mugcode.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.mugcode.cmn.mapper.DictMapper;
import com.mugcode.entity.model.cmn.Dict;
import com.mugcode.entity.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

/**
 * projectName: appointment
 * <p>
 * author: Mu
 * time: 2023/5/27 14:49
 * description:
 */
public class DictListener extends AnalysisEventListener<DictEeVo> {

    private DictMapper dictMapper;

    public DictListener(DictMapper dictMapper){
        this.dictMapper = dictMapper;
    }

    //逐行读取
    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo, dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
